<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组合式API - 只能展开一个组件</title>

</head>

<body>
    <!--
        https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/details
    -->
    <script src="https://cdn.staticfile.org/vue/3.0.5/vue.global.js"></script>
    <div id="Application">
        <details v-for="item in data" :key="item.id" @click="myClick(item.id)" :open="ins === item.id">
            <summary>{{item.title}}-{{item.id}}</summary>
            Something small enough to escape casual notice.
        </details>
        </p>



    </div>
    <script>
        const App = Vue.createApp({
            setup() {
                const data = Vue.ref([
                    { id: 1, title: "one" },
                    { id: 2, title: "two" },
                    { id: 3, title: "three" },
                ])
                //记录当前列表ID
                const ins = Vue.ref(0)
                //赋值当前点击的id
                function myClick(id) {
                    ins.value = id;
                    console.log(id)
                    console.log(ins.value === id)
                };


                return { ins, data, myClick }
            }
        })
        App.mount("#Application")
    </script>
    <style>
        .red {
            color: tomato;
        }
    </style>
</body>

</html>